﻿@model eShop.Web.Models.CategoryModel
@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>@Model.CategoryInfo.Name-@{@WorkContext.ShopConfig.SiteTitle}</title>
    @Html.Raw(WorkContext.ShopConfig.SEOKeyword)
    @Html.Raw(WorkContext.ShopConfig.SEODescription)
    <link href="@{@WorkContext.CSSCDN}/themes/default/css/base.css" rel="stylesheet" type="text/css" />
    <link href="@{@WorkContext.CSSCDN}/themes/default/css/list.css" rel="stylesheet" type="text/css" />
    <script src="@{@WorkContext.ScriptCDN}/scripts/jquery.js" type="text/javascript"></script>
    <script src="@{@WorkContext.ScriptCDN}/scripts/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        uid = @WorkContext.Uid;
        isGuestSC = @WorkContext.ShopConfig.IsGuestSC;
        scSubmitType = @WorkContext.ShopConfig.SCSubmitType;
    </script>
</head>

<body>
@Html.Partial("_header")
@{
    List<CategoryInfo> categoryList = Categories.GetCategoryList();
    //上级
    CategoryInfo categoryInfo1 = Categories.GetCategoryById(Model.CategoryInfo.ParentId, categoryList);
    if (categoryInfo1 == null)
    {
        categoryInfo1 = Categories.GetCategoryById(Model.CategoryInfo.CateId, categoryList);
    }
    //上级的上级
    //CategoryInfo categoryInfo1 = Categories.GetCategoryById(categoryInfo2.ParentId, categoryList);
}
<div class="breadcrumb box">
    <strong><a href="#">@categoryInfo1.Name</a></strong>
    <span>&nbsp;&gt;&nbsp;<a href="@Url.Action("category", new RouteValueDictionary { { "cateId", Model.CategoryInfo.CateId } })">@Model.CategoryInfo.Name</a></span>
</div>
<div class="box">
<div id="listL">
<div id="sortlist" class="m">
  <div class="mt">
    <h2>@categoryInfo1.Name</h2>
  </div>
  <div class="mc">
  @{
      int tempParentCateId = 0;
      foreach (CategoryInfo info in Categories.GetChildCategoryList(categoryInfo1.CateId, categoryInfo1.Layer, true, categoryList))
      {
          if (info.Layer == 2)
          {
              if (tempParentCateId != 0)
              {
                @:</ul></div>
            }
            @:<div class="item hot"><h3><b></b>@info.Name</h3><ul> 
            tempParentCateId = info.CateId;
          }
          else
          {
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "cateId", info.CateId } })">@info.Name</a></li>
          }
      }
    @:</ul></div>
    }
  </div>
</div>
</div>

<div id="listR">
<div id="listSelect">
<h1><b>@Model.CategoryInfo.Name</b>- 商品筛选</h1>
<div id="selectBox" @*style="height:55px"*@>
    @if (Model.FilterAttr.Length == 0)
    {
        if (Model.AAndVList.Count > 0)
        {
            StringBuilder attrRouteValue = new StringBuilder();
            for (int i = 0; i < Model.AAndVList.Count; i++)
            {
                attrRouteValue.Append("0-");
            }
            Model.FilterAttr = attrRouteValue.Remove(attrRouteValue.Length - 1, 1).ToString();
        }
        else
        {
            Model.FilterAttr = "0";
        }
    }
    @if (Model.BrandList.Count > 0)
    {
    <div class="selectItme">
        <h3>品牌：</h3>
        <ul>
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", 0 }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.BrandId == 0)
                                                                                                                                                                                                                                                                                       { <text>class="hot"</text>}>不限</a></li>
            @foreach (BrandInfo info in Model.BrandList)
            {
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", info.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.BrandId == info.BrandId)
                                                                                                                                                                                                                                                                                                  {<text>class="hot"</text>}>@info.Name</a></li>
            }
            <div class="clear"></div>
        </ul>
        <div class="clear"></div>
    </div>
    }
    @if (Model.CatePriceRangeList.Length > 0)
    {
    <div class="selectItme">
        <h3>价格：</h3>
        <ul>
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", 0 }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.FilterPrice == 0)
                                                                                                                                                                                                                                                                                   { <text>class="hot"</text>}>不限</a></li>
            @for (int i = 0; i < Model.CatePriceRangeList.Length; i++)
            {
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", i + 1 }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.FilterPrice == (i + 1))
                                                                                                                                                                                                                                                                                       { <text>class="hot"</text>}>@Model.CatePriceRangeList[i]</a></li>
            }
            <div class="clear"></div>
        </ul>
        <div class="clear"></div>
    </div>
    }
  @{
      int order = 1;
      string startStr;
      string endStr;
      string centerStr;
      foreach (KeyValuePair<AttributeInfo, List<AttributeValueInfo>> item in Model.AAndVList)
      {
          if (item.Value.Count > 0)
          {
              startStr = order != 1 ? Model.FilterAttr.Substring(0, StringHelper.IndexOf(Model.FilterAttr, order - 1) + 1) : "";
              endStr = order != Model.AAndVList.Count ? Model.FilterAttr.Substring(StringHelper.IndexOf(Model.FilterAttr, order)) : "";
              centerStr = StringHelper.TrimEnd(StringHelper.TrimStart(Model.FilterAttr, startStr), endStr);
      <div class="selectItme">
          <h3>@item.Key.Name：</h3>
          <ul>
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", startStr + "0" + endStr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (centerStr == "0")
                                                                                                                                                                                                                                                                                                          { <text>class="hot"</text>}>不限</a></li>
            @foreach (AttributeValueInfo info in item.Value)
            {
            <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", startStr + info.AttrValueId + endStr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (centerStr == info.AttrValueId.ToString())
                                                                                                                                                                                                                                                                                                                       { <text>class="hot"</text>}>@info.AttrValue</a></li>
            }
            <div class="clear"></div>
          </ul>
          <div class="clear"></div>
      </div>
            }
            order++;
          }
      }

</div>
</div>
<div class="orderList">
<dl>
    <dt>排序:</dt>
    <dd><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="@if (Model.SortColumn == 0)
                                                                                                                                                                                                                                                                                                                                 { <text>current</text>} @if (Model.SortDirection == 1 && Model.SortColumn == 0)
                                                                                                                                                                                                                                                                                                                                                         { <text>down</text>}
                                                                                                                                                                                                                                                                                                                                                         else if (Model.SortDirection == 0 && Model.SortColumn == 0)
                                                                                                                                                                                                                                                                                                                                                         { <text>up</text>}">销量</a></dd>
    <dd><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 1 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="@if (Model.SortColumn == 1)
                                                                                                                                                                                                                                                                                                                                 { <text>current</text>} @if (Model.SortDirection == 1 && Model.SortColumn == 1)
                                                                                                                                                                                                                                                                                                                                                         { <text>up</text>}
                                                                                                                                                                                                                                                                                                                                                         else if (Model.SortDirection == 0 && Model.SortColumn == 1)
                                                                                                                                                                                                                                                                                                                                                         { <text>down</text>}">价格</a></dd>
    <dd><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 2 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="@if (Model.SortColumn == 2)
                                                                                                                                                                                                                                                                                                                                 { <text>current</text>} @if (Model.SortDirection == 1 && Model.SortColumn == 2)
                                                                                                                                                                                                                                                                                                                                                         { <text>up</text>}
                                                                                                                                                                                                                                                                                                                                                         else if (Model.SortDirection == 0 && Model.SortColumn == 2)
                                                                                                                                                                                                                                                                                                                                                         { <text>down</text>}">评价</a></dd>
    <dd><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 4 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="@if (Model.SortColumn == 4)
                                                                                                                                                                                                                                                                                                                                 { <text>current</text>} @if (Model.SortDirection == 1 && Model.SortColumn == 4)
                                                                                                                                                                                                                                                                                                                                                         { <text>up</text>}
                                                                                                                                                                                                                                                                                                                                                         else if (Model.SortDirection == 0 && Model.SortColumn == 4)
                                                                                                                                                                                                                                                                                                                                                         { <text>down</text>}">人气</a></dd>
    <div class="clear"></div>
</dl>


<div class="orderPage">
    <span class="ProNB">共 @Model.PageModel.TotalCount 个商品</span>
    <span class="orderPageNB"><b>@if (Model.PageModel.TotalPages > 0)
                                 {@Model.PageModel.PageNumber}
                                 else
                                 {<text>0</text>}</b>/@Model.PageModel.TotalPages</span>
    @if (Model.PageModel.HasPrePage)
    { 
        <a href = "@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", Model.SortColumn }, { "sortDirection", Model.SortDirection }, { "page", Model.PageModel.PrePageNumber } })">上一页</a>
    }
    else
    {
        <a href="javascript:;">上一页</a>
    }
    @if (Model.PageModel.HasNextPage)
    {
        <a href = "@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", Model.SortColumn }, { "sortDirection", Model.SortDirection }, { "page", Model.PageModel.NextPageNumber } })">下一页</a>
    }
    else
    {
        <a href="javascript:;">下一页</a>
    } 
    <div class="clear"></div>
</div>

</div>



<div class="proList">

<ul>
    @foreach (PartProductInfo info in Model.ProductList)
    {
        <li>
            <a href="@Url.Action("product", new RouteValueDictionary { { "pid", info.Pid } })"><img src="@{@WorkContext.ImageCDN}/upload/product/show/thumb230_230/@info.ShowImg" width="230" height="230" /><em>@info.Name</em></a>
            <b>¥@info.ShopPrice</b>
            <div class="info">
                <div class="star"><span class="star_yellow" style=" width:@Html.Raw((info.GetStarLevel() * 20).ToString())%;">&nbsp;</span></div>
                <a href="#">已有 @info.ReviewCount 人评价</a> 
            </div>
            @*<div class="info2">
                <span onclick="addToFavorite(@info.Pid)">加入收藏</span>
                <a href="javascript:addProductToCart(@info.Pid, 1)" class="addShopping">加入购物车</a>
            </div>*@
        </li>
    }
    <div class="clear"></div>
</ul>

@Html.WebPager(Model.PageModel)

</div>

</div>
<div class="clear"></div>
</div>
@Html.Partial("_footer")
</body>
</html>